package com.mt.api.modules.manager.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mt.api.modules.domain.AppOrderDetail;
import com.mt.api.modules.manager.IOrderDetailManager;
import com.mt.api.modules.mapper.AppOrderDetailMapper;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author: plover
 * @Date: 2022-01-02
 * @Description:
 */
@Component
public class OrderDetailManagerImpl extends ServiceImpl<AppOrderDetailMapper, AppOrderDetail> implements IOrderDetailManager {

    @Override
    public List<AppOrderDetail> getListByOrderIds(List<Integer> orderIds) {
        LambdaQueryWrapper<AppOrderDetail> wrapper = Wrappers.lambdaQuery();
        wrapper.in(AppOrderDetail::getOrderId, orderIds);
        return baseMapper.selectList(wrapper);
    }

    @Override
    public List<AppOrderDetail> getOrderDetailByOrderId(Integer orderId) {
        LambdaQueryWrapper<AppOrderDetail> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(AppOrderDetail::getOrderId, orderId);
        return baseMapper.selectList(wrapper);
    }

    @Override
    public int plusOutStoreQty(Integer id, Integer qty) {
        return baseMapper.plusOutStoreQty(id, qty);
    }

    @Override
    public int subtractOutStoreQty(Integer id, Integer qty) {
        return baseMapper.subtractOutStoreQty(id, qty);
    }

    @Override
    public int getSalesQtyByCargoId(Integer cargoId) {
        return baseMapper.getSalesQtyByCargoId(cargoId);
    }

}
